package com.ssyan.adapter.objectadapter;

import com.ssyan.adapter.classadapter.IVoltage5V;

/**
 * @author ssyan
 * @Description TODO
 * @create 2021/8/28 16:51
 * @Version 1.0
 */
public class VoltageAdapter implements IVoltage5V {

    private Voltage220V voltage220V;//关联关系的聚合

    public VoltageAdapter(Voltage220V voltage220V) {
        this.voltage220V = voltage220V;
    }

    //将220V转为5V
    @Override
    public int output5V() {

        int dst = 0;
        if (voltage220V != null) {
            int src = voltage220V.output220V();//获取220V 电压
            System.out.println("使用对象适配器，进行适配~~");
            dst = src / 44;
            System.out.println("适配完成，输出的电压为=" + dst);
        }
        return dst;
    }
}
